19. 练习:最后的检测

建议使用以下环境练习你的查询,并将查询保存到文件中。然后将你的文件与下一页面中我的答案进行对比!

问题

  1. 为每个 sales_rep 对应的 region 以及相关的 accounts 创建一个表格,这次仅针对 Midwest 区域。最终表格应该包含三列:区域 名称 、销售代表 姓名 ,以及客户 名称 。根据客户名称按字母顺序 (A-Z) 排序。

  2. 为每个 sales_rep 对应的 region 以及相关的 accounts 创建一个表格,这次仅针对 Midwest 区域,并且sales_rep的名字以 S 开头。最终表格应该包含三列:区域 名称 、销售代表 姓名 ,以及客户 名称 。根据客户名称按字母顺序 (A-Z) 排序。

  3. 为每个 sales_rep 对应的 region 以及相关的 accounts 创建一个表格,这次仅针对 Midwest 区域,并且sales_rep的姓以 K 开头。最终表格应该包含三列:区域 名称 、销售代表 姓名 ,以及客户 名称 。根据客户名称按字母顺序 (A-Z) 排序。

  4. 提供每个 订单 的区域 名称 ,客户 名称 和所支付的 单价 (total_amt_usd/total)。但是,只针对 standard_qty 超过 100 的情况提供结果。最终表格应该包含三列: 区域名称 客户名称 单价 。为了避免除以 0 个订单,这里可以在分母上加上 0.01,即:(total_amt_usd/(total+0.01))。

  5. 提供每个 订单 的区域 名称 ,客户 名称 和所支付的 单价 (total_amt_usd/total)。但是,只针对 standard_qty 超过 100 poster_qty 超过 50 的情况提供结果。最终表格应该包含三列: 区域名称 客户名称 单价 。按照最低的 单价 在最之前排序。为了避免除以 0 个订单,这里可以在分母上加上 0.01,即:(total_amt_usd/(total+0.01))。

  6. 提供每个 订单 的区域 名称 ,客户 名称 和所支付的 单价 (total_amt_usd/total)。但是,只针对 standard_qty 超过 100 poster_qty 超过 50 的情况提供结果。最终表格应该包含三列: 区域名称 客户名称 单价 。按照最高的 单价 在最之前排序。为了避免除以 0 个订单,这里可以在分母上加上 0.01,即:(total_amt_usd/(total+0.01))。

  7. account id 1001 的客户使用了哪些不同的 channel 。最终表格应该包含 2 列: account 和不同的 channel 。你可以尝试使用 SELECT DISTINCT 使结果仅显示唯一的值。

  8. 找出发生在 2015 年的所有订单。最终表格应该包含 4 列: occurred_at account name order total order total_amt_usd

Workspace

This section contains either a workspace (it can be a Jupyter Notebook workspace or an online code editor work space, etc.) and it cannot be automatically downloaded to be generated here. Please access the classroom with your account and manually download the workspace to your local machine. Note that for some courses, Udacity upload the workspace files onto https://github.com/udacity , so you may be able to download them there.

Workspace Information:

  • Default file path:
  • Workspace type: sql-evaluator
  • Opened files (when workspace is loaded): n/a